package com.baizhi.app;

import com.baizhi.entity.R;
import com.baizhi.entity.User;
import com.baizhi.service.GuruArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/appArticle")
public class AppArticleController {
    @Autowired
    private GuruArticleService guruArticleService;
    @GetMapping("/selectGuruArticle")
    public R slelectGuruArticle(HttpServletRequest request){
        HttpSession session = request.getSession();
        User user = (User)session.getAttribute("user");
        R r = guruArticleService.selectByGuruId(user.getGuruId());
        return r;
    }
    @GetMapping("/selectAllArticle")
    public R selectAllArticle(){
        R r = guruArticleService.selectAllGuruArticle();
        return r;
    }
}
